package com.member.web.controller.shop;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.member.common.annotation.Log;
import com.member.common.core.controller.BaseController;
import com.member.common.core.domain.AjaxResult;
import com.member.common.core.page.TableDataInfo;
import com.member.common.enums.BusinessType;
import com.member.common.utils.poi.ExcelUtil;
import com.member.shop.domain.SysBizRankList;
import com.member.shop.service.ISysBizRankListService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 【排行榜单】控制器
 *
 * @author lixinchen
 * @version 1.0
 * @date 2025-01-11
 **/
@RestController
@RequestMapping("/shop/rankList")
public class SysBizRankListController extends BaseController {
    @Resource
    private ISysBizRankListService sysBizRankListService;

    /**
     * 查询排行榜单列表
     */
    @PreAuthorize("@ss.hasPermi('shop:rankList:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysBizRankList sysBizRankList) {
        startPage();
        List<SysBizRankList> list = sysBizRankListService.selectSysBizRankListList(sysBizRankList);
        return getDataTable(list);
    }

    /**
     * 导出排行榜单列表
     */
    @PreAuthorize("@ss.hasPermi('shop:rankList:export')")
    @Log(title = "排行榜单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysBizRankList sysBizRankList) {
        List<SysBizRankList> list = sysBizRankListService.selectSysBizRankListList(sysBizRankList);
        ExcelUtil<SysBizRankList> util = new ExcelUtil<SysBizRankList>(SysBizRankList.class);
        util.exportExcel(response, list, "排行榜单数据");
    }

    /**
     * 获取排行榜单详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:rankList:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysBizRankListService.selectSysBizRankListById(id));
    }

    /**
     * 新增排行榜单
     */
    @PreAuthorize("@ss.hasPermi('shop:rankList:add')")
    @Log(title = "排行榜单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBizRankList sysBizRankList) {
        return toAjax(sysBizRankListService.insertSysBizRankList(sysBizRankList));
    }

    /**
     * 修改排行榜单
     */
    @PreAuthorize("@ss.hasPermi('shop:rankList:edit')")
    @Log(title = "排行榜单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysBizRankList sysBizRankList) {
        return toAjax(sysBizRankListService.updateSysBizRankList(sysBizRankList));
    }

    /**
     * 删除排行榜单
     */
    @PreAuthorize("@ss.hasPermi('shop:rankList:remove')")
    @Log(title = "排行榜单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysBizRankListService.deleteSysBizRankListByIds(ids));
    }
}
